﻿using System;
using System.Data;
using System.Data.Odbc;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.OracleClient;
 
/*	-----------------------------------------------------------------------	
	Copyright:	umlungu consulting (pty) ltd
	Author:		Alan Benington
	Started:	2007-12-21	
	Status:		alpha	
	Version:	2.0.0
	Build:		20071221
	License:	GNU General Public License
	-----------------------------------------------------------------------	*/
	
/*	-------------------------------------------------------------------------------------------------
	Note re EngineX.DataX:
	------------------------------------
	This component is intended as a data layer to abstract the use of any particular data connector.
	The original source for this was taken from the following url:
		http://aspalliance.com/837
	-------------------------------------------------------------------------------------------------	*/

/*	-----------------------------------------------------------------------
	Development Notes:
	==================
	20071221:	Starting date is a pallendrome!
	20071221:	Extend for PostGreSQL
	-----------------------------------------------------------------------	*/

namespace umlungu.engineX.dataX {
	/// <summary>
	/// DataProvider enumeration ensures that we have a loose coupling between the UI layer and the Data Access Layer.
	/// It also provides a mechanism for extension to other data providers
	/// </summary>
	public enum DataProviderType {
		Oracle, 
		SqlServer, 
		/// <summary>Open source data provider for PostgreSQL</summary>
		Npgsql,
		/// <summary>Commercial data provider for PostgreSQL</summary>
		PostgreSQLDirect,
		OleDb, 
		Odbc
	}	
	/// <summary>
	/// The IDataXManager interface contains the signature of the methods that the DBManager class implements.
	/// </summary>
	public interface IDataXManager {
		#region Visible properties
		/// <summary></summary>
		/// <value></value>
		DataProviderType ProviderType {
			get;
			set;
		}
		/// <summary></summary>
		/// <value></value>
		string ConnectionString {
			get;
			set;
		}
		/// <summary></summary>
		/// <value></value>
		IDbConnection Connection {
			get;
		}
		/// <summary></summary>
		/// <value></value>
		IDbTransaction Transaction {
			get;
		}
		/// <summary></summary>
		/// <value></value>
		IDataReader DataReader {
			get;
		}
		/// <summary></summary>
		/// <value></value>
		IDbCommand Command {
			get;
		}
		/// <summary></summary>
		/// <value></value>
		IDbDataParameter[] Parameters {
			get;
		}
		#endregion

		#region Methods
		void Open();
		void BeginTransaction();
		void CommitTransaction();
		void CreateParameters(int paramsCount);
		void AddParameters(int index, string paramName, object objValue);
		IDataReader ExecuteReader(CommandType commandType, string commandText);
		DataSet ExecuteDataSet(CommandType commandType, string commandText);
		object ExecuteScalar(CommandType commandType, string commandText);
		int ExecuteNonQuery(CommandType commandType, string commandText);
		void CloseReader();
		void Close();
		void Dispose();
		#endregion
	}
}